﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Public.Common;

public partial class Search : System.Web.UI.Page
{
    public string temp_key = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int mid = MRequest.GetQueryInt("mid", 0);
            int page = MRequest.GetQueryInt("page", 1);
            int count = MRequest.GetQueryInt("count", 0);
            string keyword = MRequest.GetQueryString("keyword");
            ShowData(mid, page, count, keyword);
        }
    }

    protected void ShowData(int mid, int page, int count, string keyword)
    {
        string where = " 1>0 ";
        if (!string.IsNullOrEmpty(keyword))
        {
            temp_key = MRequest.UrlDecode(keyword);
            where += " and (Body_Name like '%" + temp_key + "%') ";

            this.Title = "包含'" + temp_key + "'的信息";
            this.Header1.HrefText=" >> 包含'" + temp_key + "'的信息";
        }
        if (mid != 0)
        {
            where += " and (Body_MuLuID2=" + mid + ")";
        }
        count = count == 0 ? WebBase.Repository.forum_body.GetCount(where) : count;
        this.Repeater1.DataSource = WebBase.CacheRepository.forum_body.GetPaged(where, " body_id desc ", page == 0 ? 0 : page - 1, 10);// Forum.Web.Main.Forum_Body.GetList("Body_ID", page, 10, where, true, null);
        this.Repeater1.DataBind();

        hb.pagelist.info_pagelist page_ = new hb.pagelist.info_pagelist(count, page, 2, 10, "Search.aspx", null);
        this.pagelist.InnerHtml = page_.html();

    }
    protected string GetNewName(object body_name)
    {
        if (!string.IsNullOrEmpty(temp_key))
            return body_name.ToString().Replace(temp_key, "<font color='#CC328C'>" + temp_key + "</font>");
        return body_name.ToString();
    }
    protected string GetMuLuName(object mid)
    {
        return WebBase.CacheRepository.forum_mulu.GetByMuLuId(int.Parse(mid.ToString())).MuLu_Name;// WebBase.GetModelByMuLuID(int.Parse(mid.ToString())).MuLu_Name;
    }

}
